/* atan2 example */
#include <stdio.h>      /* printf */
#include <math.h>       /* atan2 */
#define PI 3.14159265

struct coord {
	double x;
	double y;
};

int main ()
{
    double factor =  180 / PI;
    struct coord c1 = { 
		.x = -10.0,
		.y = 10.0,
	};
	struct coord c2 = { 
		.x = -10.0,
		.y = -10.0,
	};
    
	// atan2(y, x)*factor的结果范围为 -180 ~ 180
    printf ("The arc tangent for (x=%f, y=%f) is %f degrees\n", c1.x, c1.y, atan2(c1.y, c1.x)*factor );
	printf ("The arc tangent for (x=%f, y=%f) is %f degrees\n", c2.x, c2.y, atan2(c2.y, c2.x)*factor );
    return 0;
}

